#ifndef __TREELIST_HEAD__
#define __TREELIST_HEAD__

#include "..\DuiLib\UIlib.h"
#include <vector>
#define TREELIST_LABEL_SIZE 256
namespace DuiLib
{

	
	class CNode
	{
	public:
		CNode(bool bRoot = false) ;
		~CNode() ;
		const TCHAR* GetClass();
		CControlUI* GetObject();
		int ChildNum() ;
		void AddChild(CNode* pChild) ;
		void RemoveChild(CNode* pChild) ;
		CNode* GetChild(int nIndex) ;
		int GetCount() ;
		bool IsHasChild(CNode* pChild) ;
		void Expand();
		void Hide();
		void SetOwner(CNode* pOwner) ;
		void SetLabel(TCHAR* szText) ;
		void GetLabel(TCHAR* lpText,int nLength) ;
	private:
		TCHAR m_szLabel[TREELIST_LABEL_SIZE];
		std::vector<CNode*> m_aChildren;
		CNode* m_pOwner;
		CControlUI* m_pItem ; 
		CListUI* m_pRoot;

	};

	class CTreeListUI :public CListUI
	{
	public:
		CTreeListUI();
		~CTreeListUI();
		CNode* GetNode(int nIndex);
		bool IsHasChild(CNode* pChild);
		void AddNode(CNode* pParent ,CNode* pNode);
		void DelNode(CNode* pParent ,CNode* pNode);
		void DoEvent(TEventUI& event);

	private:
		std::vector<CNode*> m_aChildren;
		CNode* m_pRoot;
	};
}
#endif //__TREELIST_HEAD__